<?php
	// load the theme options
	$options = get_option( 'complete_theme_settings' ); 
	if($options['home_portfolio_count']) { $home_portfolio_count = $options['home_portfolio_count']; } else { $home_portfolio_count = 10; }
?>
<?php
	global $post;
	$args = array(
	'post_type' =>'Portfolio',
	'numberposts' => $home_portfolio_count,
	'orderby' => 'ASC'
	);
	$portfolio_posts = get_posts($args);
?>
<?php if($portfolio_posts) { ?>
<div id="homepage-portfolio-wrap">
<?php if($options['home_portfolio_title'] != '') { ?>
<h2><?php echo stripslashes($options['home_portfolio_title']);  ?></h2>
<?php } else { ?>
<h2><?php _e( 'Latest Work' ); ?></h2>
<?php } ?>
    <ul id="homepage-portfolio">
		<?php
        foreach($portfolio_posts as $post) : setup_postdata($post); ?>
        <?php $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'portfolio-homepage'); ?>
        <li>
            <div class="homepage-portfolio-image">
				<?php if ( has_post_thumbnail() ) {  ?>
                <a href="<?php the_permalink(' '); ?>" title="<?php the_title(' '); ?>" class="opacity"><img src="<?php echo $thumbnail[0]; ?>" alt="<?php the_title(' '); ?>" width="210" /></a>
                <?php } else { ?>
                <img src="<?php bloginfo('template_directory') ?>/images/demo.png" width="210" height="160" />
                <?php } ?>
                <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="portfolio-view-work">→</a>
            </div>
            <!-- END homepage-portfolio-image -->
        </li>
        <?php endforeach; ?>
    </ul>
</div>
<!-- END homepage-portfolio -->
<?php } wp_reset_postdata(); ?>